package io.github.yotta.export.core.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * @author yotta
 * @date 2023/10/30 13:46
 */
public enum ExcelType {

    CSV(".csv"),
    XLS(".xls"),
    XLSX(".xlsx"),
    ;

    @Getter
    private final String ext;

    ExcelType(String ext) {
        this.ext = ext;
    }


    public static com.alibaba.excel.support.ExcelTypeEnum toEasyExcelTypeEnum(ExcelType excelTypeEnum) {
        Objects.requireNonNull(excelTypeEnum);
        switch (excelTypeEnum) {
            case CSV:
                return com.alibaba.excel.support.ExcelTypeEnum.CSV;
            case XLS:
                return com.alibaba.excel.support.ExcelTypeEnum.XLS;
            case XLSX:
                return com.alibaba.excel.support.ExcelTypeEnum.XLSX;
            default:
                throw new IllegalArgumentException("unknown excel file type:" + excelTypeEnum);
        }
    }
}
